#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        if (nums.size() == 0)
            return 0;
        int left = 0;
        int right = 0;
        while (right < nums.size())
        {
            if (nums[right] != val)
            {
                nums[left] = nums[right];
                left++;
            }
            right++;
        }
        return left;
    }
};
void Test()
{
    Solution s;
    vector<int>nums;
    int val = 0;
    int i = 0;
    while (cin >> i)
    {
        nums.push_back(i);
        if (cin.get() == '\n')
        {
            break;
        }
    }
    cin >> val;
    int ret = s.removeElement(nums, val);
    cout << ret << endl;
}
int main()
{
    Test();
	return 0;
}